package screen;

import framework.Key;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;

import framework.Util;
import framework.Screen;
import game.Global;

public class TitleScreen extends Screen {

    private Image title;
    private Image back;
    private int x;
    private int speedX;

    public TitleScreen() {
        title = Util.loadImage(Global.IMG_TITLE);
        back = Util.loadImage(Global.IMG_TITLE_BACK);

        speedX = -5;
    }

    public void paint(Graphics g) {
        g.drawImage(back, x, 0, null);
        g.drawImage(back, x + back.getWidth(null), 0, null);
//        g.drawImage(title, 0, 0, null);


        g.drawImage(title, 0, 0, null);//desenha o titulo do jogo por cima das bolinhas
    }

    public void update() {
        x += speedX;

        //retorna o fundo à posicao inicial
        if (x <= -back.getWidth(null)) {
            x = 0;
        }




        if (Key.isDown(KeyEvent.VK_D) || Key.isDown(KeyEvent.VK_ENTER)) {
            // iniciar jogo
            Screen.setCurrentScreen(new GameScreen());
        } else if (Key.isDown(KeyEvent.VK_X)) {
            // tela de opcoes extras
            Screen.setCurrentScreen(new OptionScreen());
        } else if (Key.isDown(KeyEvent.VK_ESCAPE)) {
            // sair do jogo
            System.exit(0);
        }


    }
}
